package com.alks.function.controller.task;


import com.alks.common.aop.RedisLock;
import com.alks.common.utils.beanutils.ObjectUtils;
import com.alks.entity.exception.ServiceErrorException;
import com.alks.function.data.dto.chengKong.produce.PcStitchStatusDto;
import com.alks.function.data.dto.finance.fincons.SettlementDetailsDto;
import com.alks.function.data.dto.finance.fincons.SettlementSummaryDto;
import com.alks.function.data.dto.finance.fincons.SettlementSummaryDto2;
import com.alks.function.data.request.finance.fincons.SettlementPayableRequest;
import com.alks.function.mapper.finance.fincons.SettlementPayableMapper;
import com.alks.function.mapper.stockdept.pcfactorystockquery.SD_SQ_PcMtlCheckMapper;
import com.alks.function.service.finance.fincons.AnnualPayableService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 财务部
 * 厂商结算应付数据
 * 查询慢，实现定时插入新表缓解
 */
@Component
@Slf4j
@EnableScheduling
@EnableAsync
public class FinanceFinconsTask {

    @Autowired
    private SettlementPayableMapper settlementPayableMapper;

    @Autowired
    private AnnualPayableService annualPayableService;

    /**
     * 结算应付月份汇总：PC_V_COST_TTL>>>PcCostTtlTask(先全删除再写入数据)
     * PC_COST_TTL_TASK
     * 每小时的第0分钟运行
     */
    @Async("TaskExecutor")
    @Scheduled(cron = "0 0 * * * ?") // 每小时的第0分钟运行
    //@Scheduled(initialDelay = 5000, fixedRate = 86400000) // 5秒后首次执行，之后每天执行一：测试
    public void ScheduleInsertPcCostTtlTask(){
        log.info("定时任务执行开始, 结算应付月份汇总：PC_V_COST_TTL>>>PcCostTtlTask(先全删除再写入数据)");
         annualPayableService.updateStatistics();
        log.info("定时任务执行成功, 结算应付月份汇总更新完成！");
    }

}
